#ifndef __CORE_H
#define __CORE_H

#include <sys/stat.h>

#define LOG_FILE   "../.././lib/log.txt"

#ifdef _DEBUG_
#define DEBUG(format,...) \
		printf("FILE:"__FILE__",LINE:%05d:"format, __LINE__, ##__VA_ARGS__)
#else 
#define DEBUG(format,...)
#endif

#define LOG(format, ...) \
do { \
	time_t t = time(0); \
	struct tm ttt = *localtime(&t); \
	if (access("../.././lib", F_OK) != 0) \
		mkdir("../.././lib", 0777); \
		FILE *fp_log = NULL; \
		fp_log = fopen(LOG_FILE, "ab+"); \
		fprintf(fp_log, "[INFO]%4d-%02d-%02d %02d:%02d:%02d--"format"\n", \
		ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour, ttt.tm_min, ttt.tm_sec, ##__VA_ARGS__); \
		fclose(fp_log); \
} while (0)

struct account_data {
	int grace;
	char name[6];
	char code[6];
	struct account_data* next;
};

struct guess {
	int right_number;
	int biggest_number;
	int small_number;
};

struct core {
	struct account_data head;
	struct guess guess_data;
	char current_user_name[6];
};

extern struct core *init(void);
extern void run(struct core *core);
extern void init_guess_game(struct guess* core_guess_data);

#endif